/*
 * File:   ConversorCadena.cpp
 * Author: martin
 *
 * Created on September 14, 2012, 8:37 PM
 */

#include "ConversorCadena.h"
#include<sstream>
#include<cstring>
#include<iostream>

using std::string;
using std::stringstream;

ConversorCadena::ConversorCadena(){
    cadena= 0;
}

ConversorCadena::~ConversorCadena(){
    if(cadena)
        delete[] cadena;
}

char* ConversorCadena::convertir(long numero, unsigned int longitudCadena){
    if(!longitudCadena)
        return 0;
    if(cadena)
        delete[] cadena;
    cadena= new char[longitudCadena];

    string cadena_string;
    stringstream cadena_stream;

    cadena_stream<<numero;
    cadena_string= cadena_stream.str();
    strcpy(cadena,cadena_string.c_str());

    return cadena;
}//convertir


char* ConversorCadena::convertir(long numero){
    convertir(numero,TAM_MIN);
    return NULL;
}//convertir
